import { size, v2, v3, Vec3 } from "cc"

/**整个游戏中 的临时存放数据 任意地方可使用*/
export class GlobalTmpData {
    /**重置 整个游戏 的临时数据 */
    public static reset() {
        // ----------框架数据--------
        this.timeScale = 1.0;
        this.Game.isGameRun = false;
        this.Game.isGameOver = false;
        this.Game.isGuideLv = false;
        this.Game.isGuideFinish = false;
        this.Game.isGamePause = false;
        // ---------当前游戏-----------
        this.HpData = {};
        this.EndArea.p2d.set(0);
        this.EndArea.s2d.set(0);
        //
        this.Player.lpos2D.set(0);
        this.Player.wpos2D.set(0);
        this.Player.lpos3D.set(0);
        this.Player.wpos3D.set(0);
        this.Player.guideLpos3d.set(0);
        this.Player.kill = {
            boss: 0,
            army: 0,
            soldierA: 0,
            soldierB: 0,
            soldierC: 0,
            soldierD: 0,
            people: 0,
        };
        this.Player.survive = 0;
        this.Player.curCtrlNum = 0;
        this.Player.curRoleNum = 0;
        //
        this.BossArr = [];
        this.BossWarnRec = [];
        this.BuffRecs = {};
        //
        this.PartyInfo.isEnter = false;
        this.PartyInfo.isFinished = false;
        this.PartyInfo.isInPass = false;
        this.PartyInfo.isFirstInPass = false;
        this.PartyInfo.partyMark.set(0, 0, -9999);
    }

    // #region -----------框架中数据-------   
    /**游戏 dt 时间缩放值 */
    public static timeScale = 1.0;

    /**统计游戏数据 */
    public static Game = {
        isGameRun: false,
        isGameOver: false,
        isGamePause: false,
        isGuideLv: false,
        isGuideFinish: false,
        startTime: 0,       //游戏开始时间(ms)
        totalTime: 0,       //当前关卡累计运行时长(包括暂停)
        gameTime: 0,        //当前关卡累计游戏时长(不包括暂停)
        endTime: 0,         //结束时间
        gameLevel: 0,       //当前关卡
    }

    //#endregion

    // #region -----------当前游戏数据-------    

    public static EndArea = {
        p2d: v3(),
        s2d: size(),
    }

    /**存储角色的血量信息 - 用于UI显示*/
    public static HpData: {
        [uuid: string]:
        {
            isShow: boolean, rate: number, curRate: number, isPlayer: boolean, wpos: Vec3, countTime: number, type: number
            //僵尸属性
            isHide?: boolean,
            //敌军属性
            isChangeBullet?: boolean, changeBulletRate?: number,
        }
    } = {};

    //玩家位置
    public static Player = {
        lpos2D: v3(), //当前玩家的具体2d位置
        wpos2D: v3(),
        lpos3D: v3(), //当前玩家的具体3d位置
        wpos3D: v3(),
        //引导位置
        guideLpos3d: v3(),

        kill: {
            boss: 0,
            army: 0,
            soldierA: 0,
            soldierB: 0,
            soldierC: 0,
            soldierD: 0,
            people: 0,
        },
        survive: 0,     //最终存活        
        curRoleNum: 0,  //当前存活数量
        curCtrlNum: 0,  //当前控制移动的数量        
    }

    //boss、炮台位置
    public static BossArr: Vec3[] = []
    public static BossWarnRec: { p: Vec3, isWarn: boolean }[] = []

    //buff
    public static BuffRecs: { [type: number]: { num: number, curt: number, delay: number } } = {}
    //派对信息
    public static PartyInfo = {
        isEnter: false,
        isFinished: false,
        partyMark: v3(), //3d
        jumpPos: v3(),
        coffinPos: v3(),
        isInPass: false,
        isFirstInPass: false,
    }
    //#endregion

    //#region ----------miscontact--------
    public static isMiscontact = false;    //通用开关
    public static isShowMisPop = false;    //二级开关
    //#endregion

}